package com.lsh.oms.core.records;

import java.util.Map;

import static com.lsh.oms.core.records.core.Return.Status.PENDING;
import static com.lsh.oms.core.records.core.Return.Status.TERMINATED;
import static java.util.Collections.emptyMap;

public class DirectDeliverReturn extends ReturnRecord {

    @Override
    public void start() {
        run(emptyMap());
    }

    @Override
    public void run(Map<String, Object> request) {
        preDeliver(request);
    }

    @Override
    public void preDeliver(Map<String, Object> request) {
        deliver(request);
    }

    @Override
    public void deliver(Map<String, Object> request) {
        check(request);
    }

    @Override
    public void check(Map<String, Object> request) {
        returned(request);
    }

    @Override
    public void cancel(Map<String, Object> request) {

    }

    @Override
    public void refund(Map<String, Object> request) {

    }

    @Override
    public void returned(Map<String, Object> request) {
        terminate(request);
    }

    @Override
    public void terminate(Map<String, Object> request) {
        change($ -> this.status = TERMINATED, PENDING);
    }
}
